<template>
    <el-card v-loading="loading" shadow="never">
      <el-form :model="form" label-width="180px">
      
            <el-form-item label="用戶協議">
              <Editor v-model="form.content" />
            </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit">保存</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </template>
  
  <script setup>
  import { reactive, ref } from "vue";
  import { getagreement, updateagreement } from "@/api/query.js";
  import { msg } from "@/composables/util";
  import Editor from "@/components/Editor.vue";
  const form = reactive({
    
    content: "",
   
  });
  const loading = ref(false);
 
  function getData() {
    loading.value = true;
    getagreement()
      .then((res) => {
      form.content=res.content
      })
      .finally((err) => {
        loading.value = false;
      });
  }
  
  getData();
  
  const submit = () => {
    loading.value = true;
    updateagreement(1, form)
      .then((res) => {
        msg("修改成功");
      })
      .finally(() => {
        loading.value = false;
      });
  };
  </script>
  